import { http } from '@/utils/http/axios';
import { RequestEnum } from "@/enums/httpEnum";

export enum BlackTypeEnum {
  IP = 'IP',
  USER = 'USER'
}

/**
 * 获取黑名单分页
 */
export const getBlackPage = ({pageNum, pageSize}) => {
  return http.request({
    url: `/black/page/${pageNum}/${pageSize}`,
    method: RequestEnum.GET
  })
}

/**
 * 添加到黑名单
 */
export const addBlack = (data: {type: BlackTypeEnum, target: string}) => {
  return http.request({
    url: `/black/add`,
    method: RequestEnum.POST,
    data
  }, {
    isShowSuccessMessage: true
  })
}

/**
 * 从黑名单中移除
 */
export const removeBlack = id => {
  return http.request({
    url: `/black/remove/${id}`,
    method: RequestEnum.DELETE
  }, {
    isShowSuccessMessage: true
  })
}
